package com.example.springbootrabbitmq;

import com.example.springbootrabbitmq.sender.Sender;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class SpringBootRabbitmqApplication implements CommandLineRunner {

    @Autowired
    private Sender sender;

    public static void main(String[] args) {
        SpringApplication.run(SpringBootRabbitmqApplication.class, args);
    }


    /**
     * 定义目的地即队列，队列名称为my-queue
     */
    @Bean
    public Queue wiselyQueue() {
        return new Queue("my-queue");
    }

    @Override
    public void run(String... args) throws Exception {
        sender.send();
    }
}
